package org.chench.test.hiserviceclient.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * Desc: 注册Bean
 * Name: org.chench.test.hiserviceclient.config.BeanConfig
 * Author: chench9@lenovo.com
 * Date: 2018/4/19 15:14
 **/
@Configuration
public class BeanRegister {

    /**
     * REST客户端,开启负载均衡
     * @return
     */
    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * 收集跟踪信息策略，使用AlwaysSampler覆盖默认的AlwaysSampler策略
     * @return
     */
    @Bean
    public AlwaysSampler defaultSampler() {
        return new AlwaysSampler();
    }

}
